<?php
/**
 * Created by PhpStorm.
 * User:吴鑫
 */

namespace backend\service;

use common\models\Evalu;
use yii\data\Pagination;
use yii\db\Query ;
use Yii ;

class EvaluService
{

    /**
     * 评价列表
     * @param $limit
     * @param null $searchData
     * @param null $orderby
     * @return array
     */
    public static function findEvaluList($limit,$searchData=null,$orderby=null){
        $pages = null ;
        $query = new Query();

        $query->select('*')
            ->from(Evalu::tableName()) ;

        if(!empty($searchData['status']) && $searchData['status']!=-1){
            $query->andWhere(["status"=>$searchData['status']]) ;
        }


        if(!empty($orderby)){
            $query->orderBy($orderby) ;
        }else{
            $query->orderBy("id desc") ;
        }

        if(isset($limit)){
            $pages = new Pagination(['totalCount' =>$query->count(), 'defaultPageSize' => $limit]);
            $query->offset($pages->offset)
                ->limit($limit) ;
        }

        $dataList = $query->all() ;

        return ["list" => $dataList, "page" => $pages];

    }


}